﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GUI.Controllers;
using BusinessObjects.Objects;

namespace GUI.Controls
{
	public partial class OrganisationList : UserControl
	{
		public OrganisationList()
		{
			InitializeComponent();
            this.organisationListDataGridView.DataSource = "organisationListBindingSource";
            InitFields();
		}

        private void InitFields() {
            this.OrgKey.DataPropertyName = "OrgKey";
            this.OrgName.DataPropertyName = "OrgName";
            this.OrgName.SortMode = DataGridViewColumnSortMode.Automatic;
            this.Adresse.DataPropertyName = "Adresse";
            this.Straße.DataPropertyName = "Straße";
            this.Straße.SortMode = DataGridViewColumnSortMode.Automatic;
            this.TelNr1.DataPropertyName = "TelNr1";
            this.FaxNr.DataPropertyName = "FaxNr";
        }

		private void btnNewOrganisation_Click(object sender, EventArgs e)
		{
			OrganisationController newController = new OrganisationController();
			newController.OpenDialog(true);
		}

		

        private void organisationListDataGridView_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) {
            DataGridView dv = sender as DataGridView;
            DataGridViewRow row = dv.CurrentRow;

            OrganisationObject organisationObject = row.DataBoundItem as OrganisationObject;

            OrganisationController orgController = new OrganisationController();
            orgController.OpenDialog(organisationObject, true);
        }

        

        
	}
}
